package com.jt.config;

import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.print.attribute.standard.JobOriginatingUserName;

@Configuration  //标识我是一个配置类
@ComponentScan( "com.jt")  //如果注解中只有value属性则可以省略
@PropertySource(value = "classpath:/user.properties",encoding = "utf-8")
public class SpringConfig {

    @Value("${user.id}")
    private Integer id;
    @Value("${user.username}")
    private String username;

    @Bean
    public User user(){
        User user = new User();
        user.setId(id);
        user.setUsername(username);
        return user;
    }


}
